package review;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

/**
 * Create By IntelliJ IDEA
 *
 * @Author: jsonor
 * @Create-Time: 2017/10/12 8:18
 * @Description: 初始化 数据
 */

/**
 * loadOnStartup: 默认值为-1，表示，第一次访问该Servlet的时候，生成一个Servlet的对象
 *                如果大于0（1-5）,表示tomcat启动的时候就生成一个放那
 */
@WebServlet(name = "init", urlPatterns = {"/init"},loadOnStartup = 3)
public class InitServlet extends HttpServlet {

  @Override
  public void init() throws ServletException {
    ServletContext context = this.getServletContext();
    context.setAttribute("name", "zjitc");

    System.out.println("context init success, add key = name, value = zjitc");
  }
}
